//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System.Collections;
using CommunityServer.Components;

namespace CommunityServer.Galleries.Components
{
	/// <summary>
	/// Generates an XML feed by a specific category
	/// </summary>
	public class GalleryCategoryRssWriter : GalleryRssWriter
	{

		protected ArrayList categories;

		public GalleryCategoryRssWriter(ArrayList categories, Gallery gallery, string baseUrl) : base(new ArrayList(), gallery, baseUrl)
		{
			this.categories = categories;
		}

        //Should we support enclosures?
        protected override string EnclosureUrl(PostAttachmentMetaData pa)
        {
            return null;
        }

        protected override void WritePostEnclosure(Post p)
        {
            
        }

		/// <summary>
		/// Appends the CategoryName to Title element
		/// </summary>
		protected override string Title
		{
			get
			{
				return string.Concat(base.Title, " : ", Category.Name);
			}
		}

		protected override void WriteChannel()
		{
			foreach(PostCategory c in categories)
			{
				Category = c;
				// Determine whether to write Categories or Tags to the RSS feed
				if (CurrentGallery.CategorizationType == CategorizationType.Album)
					BuildChannel(GalleryUrls.Instance().ViewCategory(CurrentGallery.ApplicationKey, c.CategoryID), c.Description, CurrentGallery.DefaultLanguage);
				else
					BuildChannel(GalleryUrls.Instance().TagsBrowser(CurrentGallery.ApplicationKey, new string[] {c.Name}), string.Format("{0}: {1}", ResourceManager.GetString("Tags"), c.Name), CurrentGallery.DefaultLanguage);
			}
		}

		protected override bool AllowComments
		{
			get
			{
				return base.AllowComments && CurrentGallery.EnableCommentsDefault;
			}
		}


	}
}
